﻿<UserControl x:Class="EQual.MainModule.Documents.Forms.DocumentFormsView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Models="clr-namespace:EQual.MainModule" 
    xmlns:WpfApplicationExperimental="clr-namespace:WpfApplicationExperimental;assembly=WpfApplicationExperimental"
    xmlns:loc="clr-namespace:RootLibrary.WPF.Localization;assembly=LocalizeExtension"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" >
    <UserControl.Resources >

        <ObjectDataProvider x:Key="DocumentsTypes" ObjectType="{x:Type Models:DocumentsProvider}" MethodName="GetDocumentTypes" />
        <loc:LocalizationConverter  x:Key="BaseLocalizationConverter" />
    </UserControl.Resources>
    <Grid>
        <dg:DataGrid  Name="dataGrid1"  
                      CanUserAddRows="True"
                      Background="Transparent" 
                      AutoGenerateColumns="False"
                      ItemsSource="{Binding Path=ItemsCollection}" SelectionChanged="dataGrid1_SelectionChanged" RowEditEnding="dataGrid1_RowEditEnding">

            <dg:DataGrid.Columns >
                <dg:DataGridTextColumn Binding="{Binding Id}" Header="{LocText EQualApplication:ResTexts:DocumentId}" />
                <dg:DataGridTextColumn Binding="{Binding Path=Title}" Header="{LocText EQualApplication:ResTexts:DocumentTitle}"/>
                <dg:DataGridComboBoxColumn SelectedValueBinding="{Binding Path=Type}"                                            
                                           SelectedValuePath="id"
                                           DisplayMemberPath="name"
                                           
                                           Header="{LocText EQualApplication:ResTexts:DocumentType}"
                                           ItemsSource="{Binding Source={StaticResource DocumentsTypes}}">
                    <dg:DataGridComboBoxColumn.EditingElementStyle>
                        <Style TargetType="ComboBox">
                            <Setter Property="IsEditable" Value="True" />
                        </Style>
                    </dg:DataGridComboBoxColumn.EditingElementStyle>
                </dg:DataGridComboBoxColumn>

                <dg:DataGridTemplateColumn Header="{LocText EQualApplication:ResTexts:DocumentAttachment}" Width="Auto">

                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <StackPanel >
                                <WpfApplicationExperimental:FileIconControl OnExitingDocument="FileIconControl_OnExitingDocument" Name="FileIconControl" Attachment="{Binding Attachment1}"/>
                                <TextBlock Text="{Binding Path=Attachment1.Name  , StringFormat=d}" />
                            </StackPanel>
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                    <!---->
                        <dg:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel >

                                    <TextBlock Text="{Binding Path=Attachment1.Name  , StringFormat=d}" />
                               </StackPanel>
                            </DataTemplate>
                        </dg:DataGridTemplateColumn.CellTemplate>
        </dg:DataGridTemplateColumn>

            </dg:DataGrid.Columns>
        </dg:DataGrid>
    </Grid>
</UserControl>
